package com.gxh.controller.user;


import com.gxh.entity.Swiper;
import com.gxh.result.Result;
import com.gxh.service.SwiperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userSwiperController")
@RequestMapping("/user/swiper")
@Slf4j
@Api(tags = "用户-轮播图")
public class SwiperController {

    @Autowired
    private SwiperService  swiperService;

    /**
     * 获取轮播图列表
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取轮播图列表")
    @Cacheable(value = "swiperCache",key = "'list'")
    public Result<List<Swiper>> list() {
        List<Swiper> swiperList = swiperService.list();
        return Result.success(swiperList);
    }

}
